//
//  HomeHeadLineView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 16.03.25.
//

import SwiftUI

struct HomeHeadView: View {

    @Binding var date: Date
    @Binding var book: AccountingBook
    
    var onBookClick: ()-> Void
    var onDateLeftClick: (Date) -> Void
    var onDateRightClick: (Date) -> Void
    
    var body: some View {
        HStack {
            Button(action: {
                onBookClick()
            }) {
                BookNameView(book: book, style: .large)
            }.buttonStyle(PlainButtonStyle())
            Spacer()
            DateSelectView(
                date: $date,
                dateType: .month,
                leftClick: { date in
                    onDateLeftClick(date)
                },
                rightClick: { date in
                    onDateRightClick(date)
                }
            )
        }
    }
}

@available(iOS 18.0, *)
#Preview {
    @Previewable @State var date = Date()
    @Previewable @State var book = AccountingBook(bookName: "默认账本")
    
    HomeHeadView(date: $date, book: $book, onBookClick:{}, onDateLeftClick: { _ in }, onDateRightClick: { _ in })
}
